FROM ubuntu:20.04

# 设置时区，防止安装 tzdata 时交互卡死
ENV TZ=Asia/Shanghai
RUN apt-get update && \
    apt-get install -y tzdata && \
    ln -fs /usr/share/zoneinfo/$TZ /etc/localtime && \
    dpkg-reconfigure --frontend noninteractive tzdata

# 安装构建 Nginx 所需的依赖
RUN apt-get install -y wget curl git build-essential libpcre3 libpcre3-dev zlib1g zlib1g-dev openssl libssl-dev dos2unix

# 下载并解压 Nginx 源码
RUN wget https://nginx.org/download/nginx-1.24.0.tar.gz && \
    tar -zxvf nginx-1.24.0.tar.gz


# 复制本地模块到镜像中
COPY nginx-http-flv-module /usr/local/nginx-http-flv-module
    # 修复模块 config 文件换行符问题
RUN dos2unix /usr/local/nginx-http-flv-module/config
# 编译安装 Nginx，添加 flv 模块
RUN cd nginx-1.24.0 && \
    ./configure \
        --with-http_ssl_module \
        --with-stream \
        --with-stream_ssl_module \
        --add-module=/usr/local/nginx-http-flv-module && \
    make && \
    make install

# 拷贝 nginx.conf 到容器内
COPY nginx.conf /usr/local/nginx/conf/nginx.conf

# 开放端口
EXPOSE 80 1935

# 启动命令
CMD ["/usr/local/nginx/sbin/nginx", "-g", "daemon off;"]

